#ifndef GAME_H
#define GAME_H

#include "StateManager.h"
#include "BitmapFont.h"
#include "GUI.h"

using namespace Cvekas;

class Game: public State
{
public:
	Game(RendererPtr main_renderer, BitmapFontPtr font, SpriteBatchPtr sprite_batch);
	~Game();

	// Cvekas::State implementation
	virtual void init();
	virtual void close();

	virtual void activate(const StateManager& state_manager) {};
	virtual void deactivate(const StateManager& state_manager) {};

	virtual void update(const StateManager& state_manager) {};
	virtual void render(const StateManager& state_manager);
	virtual void fade(const StateManager& state_manager, float amount, uint from, uint to);

	void draw_well(const Color& color = Color(255, 255, 255, 255));
	void reset();

private:
	enum BlockColor
	{
		EMPTY = 0,
		RED = 1,
		GREEN = 2,
		BLUE = 3
	};

	// Returns source rectangle for correct box frame
	RectF getBlockSource(BlockColor color, uint frame);

	// Constants
	static const uint block_width = 48;
	static const uint block_height = 48;
	static const uint well_x = 24;
	static const uint well_y = 24;
	static const uint well_height = 15;
	static const uint well_width = 12;

	// Game state
	BlockColor well[well_width][well_height];

	GUIPtr gui;
	BitmapFontPtr font;
	SpriteBatchPtr sprite_batch;

	// Textures
	Texture2DPtr tex_blocks;
};

typedef boost::shared_ptr<Game> GamePtr;

#endif